import {
  Body,
  Controller,
  Post,
  UseGuards,
} from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { EvaluationService } from './evaluation.service';
import { EvaluationOpenApiIndexDto } from "@/module/evaluation/evaluation.dto";
import {
  EvaluationOpenapiIndexResult
} from "@/module/evaluation/evaluation.result";
import { ApiPaginatedOkResponse } from "@/common/pager-response/api-paginated-ok-response.decorator";
import { PageResult } from "common/interface";
import { getPager } from "@/common/pager-response";
import { OpenApiAuthGuard } from '@/common/auth/open-api-auth.guard';

@Controller('/v1/openapi/evaluations')
@ApiTags('Evaluation_openapi')
@UseGuards(OpenApiAuthGuard)
export class EvaluationV1OpenapiController {
  constructor(private readonly evaluationService: EvaluationService) {
  }

  @Post('/')
  @ApiOperation({ summary: '列表' })
  @ApiPaginatedOkResponse(EvaluationOpenapiIndexResult)
  async index(
    @Body() body: EvaluationOpenApiIndexDto,
  ): Promise<PageResult<EvaluationOpenapiIndexResult>> {
    const res = await this.evaluationService.openapiIndex(body);
    return getPager(...res);
  }
}
